#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    :   4.py
@Time    :   2020/03/15 22:56:51
@Author  :   Malygos_l 
@Version :   1.0
@Contact :   751756061@qq.com
@WebSite :   www.gitee.com/malygos_l
'''
# Start typing your code from here
# 写函数，统计字符串中有几个字母，几个数字，几个空格，几个其他字符，并返回结果;

str = "I am iron man.1234567"
def statistics(str):
    dict = {"char":0,"number":0,"space":0,"others":0}
    for a in list(str):
        if a.isalpha():
            dict["char"] += 1
        elif a.isdigit():
            dict["number"] += 1
        elif a.isspace():
            dict["space"] += 1
        else: dict["others"] += 1
    print("字母个数：{0} 数字个数：{1} 空格个数：{2} 其它字符个数：{3}".format(dict["char"],dict["number"],dict["space"],dict["others"]))

statistics(str)